import torch
def Target2vec(target):
    """
        input:  Target
        return: one-hot
    """
    one_hot = [0,0,0,0,0]
    one_hot[target-1] = 1
    
    return one_hot
def Vec2target(vec):
    """
        input:  one-hot
        return: text
    """
    
    target = torch.argmax(vec,0).item() + 1
    return target

def Target2text(target):
    text_dict = {1:"融合节拍",2:"正常",3:"未能分类的节拍",4:"室上性异常节拍",5:"心室异常节拍"}
    try:
        text = text_dict[target]
    except:
        text = None
    return text
